<template>
    <!--<div style="width: 100%">
        <headerNav :title="title" :balance="balance" :iccid="iccid" :openid="openid"></headerNav>
        <footerNav :iccid="iccid"></footerNav>
        <rightBottom v-bind:iccid="iccid" v-bind:openid="openid"></rightBottom>
        <van-form style="width: 95%;margin: 10% auto;text-align: center" @submit="onSubmit">
            <van-field
                    v-model="realName"
                    name="realName"
                    label="姓名"
                    placeholder="姓名"
                    maxlength="10"
                    :rules="[{ required: true, message: '请填写姓名' }]"
            />
            <van-field
                    @blur="blurIdCard"
                    v-model="idCardNo"
                    name="idCardNo"
                    label="身份证号"
                    placeholder="身份证号"
                    :rules="[{ required: true, message: '请填写身份证号' }]"
            />
            <van-field
                    v-model="mobile"
                    name="mobile"
                    label="手机号"
                    placeholder="手机号"
                    :rules="[{ required: true, message: '请填写手机号' }]"
            />
            &lt;!&ndash;<van-field name="uploader" label="身份证正面">
                <template #input>
                    <van-uploader v-model="uploader" />
                </template>
            </van-field>
            <van-field name="uploader" label="身份证反面">
                <template #input>
                    <van-uploader v-model="uploader" />
                </template>
            </van-field>
            <van-field name="uploader" label="手持照片">
                <template #input>
                    <van-uploader v-model="uploader" />
                </template>
            </van-field>&ndash;&gt;
            <div style="margin: 16px;">
                <van-button round block type="info" native-type="submit">
                    提交
                </van-button>
            </div>
        </van-form>
    </div>
-->
</template>

<script>
    import headerNav from "../../../components/headerNav";
    import footerNav from "../../../components/footerNav";
    import rightBottom from "../../../components/rightBottom";


    export default {
        name: "card_auth",
        components:{
            "headerNav":headerNav,
            "footerNav":footerNav,
            "rightBottom":rightBottom
        },
        mounted() {
            let _this=this
            _this.iccid=_this.$store.state.iccid
        },
        data() {
            return {
                title:'实名认证',
                realName: '',
                idCardNo: '',
                mobile:"",
                iccid:"",
                balance:0.00,
                openid:''

            };
        },
        methods: {
            blurIdCard(){
                let _this=this
                if(!this.$check.checkIdCardNo(_this.idCardNo)){
                    this.$toast.fail("身份证格式有误")
                    return false
                }
            },
            onSubmit(values) {
                let _this=this
                if(!_this.$check.checkIdCardNo(values.idCardNo)){
                    return _this.$toast.fail("身份证号校验")
                }
                _this.$ajax.post(process.env.VUE_APP_SERVER+"/web/wx/auth/add-auth",{
                    "iccid":_this.iccid,
                    "realName":values.realName,
                    "idCardNo":values.idCardNo,
                    "mobile":values.mobile
                }).then(res=>{
                    if(res.data.code==="0"){
                        //跳转对应的官方实名连接
                        if(res.data.data!=="0"){
                            location.href=res.data.data
                        }else{
                            _this.$toast.success("已提交")
                            setTimeout(function () {
                                history.go(-1)
                            },3000)
                        }
                    }else{
                        _this.$toast.fail(res.data.msg)
                        _this.username=''
                        _this.idcard=''
                        _this.mobile=''
                    }
                })
            },
        },
    }
</script>

<style scoped>

</style>